package com.kevin.session;

import com.kevin.action.builder.BaseSqlBuildHandler;
import com.kevin.action.builder.MssqlBuildHandler;
import com.kevin.action.builder.MysqlBuildHandler;
import com.kevin.action.builder.OracleBuildHandler;
import com.kevin.datasource.Environment;
import com.kevin.enums.DBType;
import com.kevin.executors.Executor;
import com.kevin.executors.SimpleExecutor;
import com.kevin.transaction.Transaction;

public class Configuration {
	public Configuration() {

	}

	public Configuration(Environment environment) {
		this.environment = environment;
	}

	protected Environment environment;

	private DBType dbType = DBType.MYSQL;


	public Executor newExecutor(Transaction transaction) {
		Executor executor = new SimpleExecutor(this, transaction);
		return executor;
	}

	public BaseSqlBuildHandler newSqlBuildHandler(String tableName, Executor executor) {		
		switch (dbType) {
		case MYSQL:
			return new MysqlBuildHandler(tableName, executor);
		case MSSQL:
			return new MssqlBuildHandler(tableName, executor);
		case ORACLE:
			return new OracleBuildHandler(tableName, executor);
		default:
			return null;
		}
	}



	public Environment getEnvironment() {
		return environment;
	}

	public void setEnvironment(Environment environment) {
		this.environment = environment;
	}

	public DBType getDbType() {
		return dbType;
	}

}
